<template>
	<view class="box">
		<view class="list">
			<view class="item" v-for="(item, index) in list" :key="item.id">
				<view class="flex">
					<image :src="item.big_pic_url" mode="aspectFill"></image>
					{{ item.name }}
				</view>
				<view class="itemBody">
					<view class="ite" v-for="(ite, inde) in item.child" :key="ite.id" @click="navTo(ite.id)">
						<!-- <image :src="ite.pic_url" mode="aspectFit"></image> -->
						<view class="name">{{ ite.name }}</view>
						<view class="sub">{{ ite.subtitle }}</view>
					</view>
				</view>
				<view class="line"></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				banner: [],
				list: []
			};
		},
		methods: {
			navTo(id) {
				uni.navigateTo({
					url: '/pages/cats/cats?options.cat_id=' + id
				});
			},
			async getProduct() {
				const res = await this.$request({
					url: this.$api.default.cat_list
				})
				if (res.code == 0) {
					this.list = res.data.list
				}
			}
		},
		created() {
			this.getProduct();
		},
	};
</script>

<style lang="scss">
	.line {
		background-color: #eee;
		height: 10rpx;
		margin: 80rpx 0;
	}

	.more {
		text-align: center;
		font-size: 0.8em;
		margin-top: 20upx;
		margin-bottom: 80upx;
	}

	.cur {
		color: #000 !important;
		border-bottom: 1px solid !important;
	}

	.box {
		background-color: #fff;

		.list {
			padding: 24rpx 24rpx 0 24rpx;

			.item {
				margin: 30upx 0;

				.flex {
					display: flex;
					align-items: center;
					color: #1a1915;
					font-family: '黑体';
					letter-spacing: 2px;
					font-size: 28rpx;

					image {
						width: 40rpx;
						height: 40rpx;
						margin-right: 20rpx;
					}
				}

				.itemBody {
					display: flex;
					margin-top: 20upx;
					flex-wrap: wrap;
					justify-content: space-between;

					.ite {
						margin: 20upx 0;
						width: calc(50% - 20rpx);
						display: flex;
						flex-direction: column;
						align-items: center;
						background-color: #2a2a2a;
						justify-content: center;
						color: #fff;
						height: 150rpx;
						border-radius: 10rpx;
						text-align: center;
						// image {
						// 	width:150rpx;
						// 	height:150rpx;
						// 	border-radius: 30rpx;
						// }

						.name {
							padding: 20upx 20upx;
							font-size: 0.8em;
						}

						.sub {
							font-size: 24rpx;
							color: #999
						}
					}
				}
			}
		}
	}
</style>